<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <link rel="stylesheet" href="${ctx}/libjs/plugins/h-ui/css/H-ui.admin.css">
    <link rel="stylesheet" href="${ctx}/libjs/plugins/h-ui/style.css">
<%--    <script type="text/javascript" src="${ctx}/libjs/plugins/bootstrap-table/bootstrap-table-editor.js"></script>--%>
    <script type="text/javascript" src="${ctx}/appjs/enterprise/gain/enterpriseGain.js"></script>
    <style>
        .form-group img {
            cursor: pointer
        }

        th,td {
            border-right: 1px solid #eee;
        }
        .rowAddDelBtn {
            line-height: 19.5px;
            margin: 2px;
            color: white;
            width: 20px;
            height: 20px;
            border-radius: 10px;
            border: none;
            font-size: 15px;
            display: inline-block;
        }
        #asubtableBody tr:first-child .rowDelBtn {
            display: none;
        }
    </style>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>企业用户管理</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>新增权益</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="columns pull-left">
                        <h5 class="font-bold">新增企业权益</h5>
                    </div>
                    <div class="ibox-tools">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="frm">
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">企业等级：</label>
                            <div class="col-sm-4">
                                <select id="enterpriseLevel" name="enterpriseLevel" class="form-control" placeholder="">
                                    <option value="" selected="selected">请选择</option>
                                    <c:forEach items="${level}" var="bean">
                                        <option value="${bean.enterpriseLevel}">${bean.levelName}
                                        </option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">权益名称：</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control"  name="gainName" >
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">图标：</label>
                            <div class="col-sm-8">
                                <div >
                                    <div>
                                        <img id="exampleImage" src="${ctx}/statics/img/upload-img.png"
                                             style="position: relative" width="155px" height="120px">
                                    </div>
                                    <input type="file" id="file1" name="file1"/>
                                    <input type="hidden" id="gainLogo" name="gainLogo" value=""/>
                                </div>
                                <span>图片尺寸建议为：<span class="text-danger">98px*75px</span></span>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">权益类型：</label>
                            <div class="col-sm-8">
                                <input  type="radio" name="gainType" value="0" onchange="" checked/>充值消费折扣
                                <input  type="radio" name="gainType" value="1" onchange=""/>尊享标识
                            </div>
                        </div>
<%--                        <div class="form-group row">--%>
<%--                            <label class="col-sm-3 col-form-label text-right">&nbsp;</label>--%>
<%--                            <div class="col-sm-8">--%>
<%--&lt;%&ndash;                                <a rel="nofollow" href="javascript:;" onclick="addEnterpriseGain.addRow()" class="btn btn-primary" id="addRow">新增档位</a>&ndash;%&gt;--%>
<%--                                <table id="asubtable" class="col-sm-8 col-form-label text-left" style="color: gray;border-top: 1px solid #e5e6e7;border-left: 1px solid #e5e6e7; font-size: 14px ;line-height: 30px;">--%>
<%--                                    <thead style="display: block;background-color: #b4dbed;">--%>
<%--                                        <th style="min-width: 55px; text-align: center;"><i class="fa fa-gear"></i></th>--%>
<%--                                        <th style="min-width: 100px; text-align: center;">档位</th>--%>
<%--                                        <th style="min-width: 200px; text-align: center;">充值金额</th>--%>
<%--                                        <th style="min-width: 200px; text-align: center;">消费折扣</th>--%>
<%--                                    </thead>--%>
<%--                                    <tbody id="asubtableBody" style="display: block;" >--%>
<%--                                    <tr>--%>
<%--                                        <td style="min-width: 55px; text-align: center;">--%>
<%--                                            <div class="rowAddDelBtn rowAddBtn" style="background-color: #ff5581;font-size: 15px !important;">+</div>--%>
<%--                                            <div class="rowAddDelBtn rowDelBtn" style="background-color: greenyellow;">-</div>--%>
<%--                                        </td>--%>
<%--                                        <td style="min-width: 100px; text-align: center;">1</td>--%>
<%--                                        <td style="min-width: 200px; text-align: center;">--%>
<%--                                            <input type="number" name="rechargeAmount" id="' + rechargeAmount + '" maxlength="100" style="width: 90%; height: 22px; border: 1px solid #e6e6e6;"/>--%>
<%--                                        </td>--%>
<%--                                        <td style="min-width: 200px; text-align: center;">--%>
<%--                                            <input type="number" name="discountAmount" id="' + discountAmount + '" maxlength="100" style="width: 90%; height: 22px; border: 1px solid #e6e6e6;"/>--%>
<%--                                        </td>--%>
<%--                                    </tr>--%>
<%--                                    </tbody>--%>
<%--                                </table>--%>
<%--                            </div>--%>
<%--&lt;%&ndash;                            <div id="tableId" class="col-sm-3 col-form-label text-right" >&ndash;%&gt;--%>
<%--&lt;%&ndash;                                <input type="button" onclick="addTb('bableId')" value="添加" />&ndash;%&gt;--%>
<%--&lt;%&ndash;                                <input type="button" onclick="deleteTb('bableId')" value="删除" />&ndash;%&gt;--%>
<%--&lt;%&ndash;                                <table id="bableId">&ndash;%&gt;--%>
<%--&lt;%&ndash;                                    <tr>&ndash;%&gt;--%>
<%--&lt;%&ndash;                                        <th style="min-width: 55px; text-align: center;">选项</th>&ndash;%&gt;--%>
<%--&lt;%&ndash;                                        <th style="min-width: 100px; text-align: center;">档位</th>&ndash;%&gt;--%>
<%--&lt;%&ndash;                                        <th style="min-width: 200px; text-align: center;">充值金额</th>&ndash;%&gt;--%>
<%--&lt;%&ndash;                                        <th style="min-width: 200px; text-align: center;">消费折扣</th>&ndash;%&gt;--%>
<%--&lt;%&ndash;                                    </tr>&ndash;%&gt;--%>
<%--&lt;%&ndash;                                    <!--循环代码加载此处-->&ndash;%&gt;--%>
<%--&lt;%&ndash;                                </table>&ndash;%&gt;--%>
<%--&lt;%&ndash;                           </div>&ndash;%&gt;--%>
<%--                        </div>--%>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">权益说明：</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" name="gainExplain" >
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">排序：</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" name="sort">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">状态：</label>
                            <div class="col-sm-4">
                                <select class="form-control" name="status" id="status">
                                    <option value="0">启用</option>
                                    <option value="1">停用</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-3 col-sm-offset-8 text-right">
                                <button type="submit" class="btn btn-success">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    addEnterpriseGain.init();

    $(function(){
        //新增行
        $("#asubtableBody").on('click','tr  .rowAddBtn',function(){
            var rowHtml = $(this).parent().parent().html();
            console.log("rowHtml:",rowHtml);
            $(this).parent().parent().parent().append("<tr>"+rowHtml+"</tr>");
            renderTBody("asubtableBody");
        });
        //删除行
        $("#asubtableBody").on('click','tr  .rowDelBtn',function(){
            $(this).parent().parent().remove();
            renderTBody("asubtableBody");
        });
    });
    //重载表单中的“档位”值
    function renderTBody(bodyId) {
        $("#"+bodyId).find("tr").each(function(index,element){
            $(element).find("td").eq(1).text(index+1);
        });
    }
    $("#file1").change(function () {
        var file = this.files[0];
        var reg = RegExp(/image/);
        if (!reg.test(file.type)) {
            parent.layer.msg("支持图片上传");
            return;
        }
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#exampleImage").attr("src", objUrl);
        }
    });

    function getObjectURL(file) {
        var url = null;
        if (window.createObjectURL != undefined) {
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }

</script>
</body>
</html>
